<template>
    <div class="basis-info">
        <div class="basis_content">
            <Form ref="proposalApplicationFrom" :model="productImplemente" :rules="proposalApplicationFormValidate" :label-width="140">
                <div>
                    <Row>
                        <Col span="12">
                            <FormItem label="审批意见" prop="approveSuggest" :required=true>
                                <Select v-model="productImplemente.approveSuggest" placeholder="请选择业务类型" style="width: 80%">
                                    <Option value="submit">提交</Option>
                                    <Option value="back" v-if="isBack">退回</Option>
                                </Select>
                            </FormItem>
                        </Col>
                    </Row>
                    <Row>
                        <Col span="24">
                            <FormItem label="审批备注" prop="approvalRemarks">
                                <Input v-model="productImplemente.approvalRemarks" style="width: 90%" :autosize="true" type="textarea" placeholder="请输入"/>
                            </FormItem>
                        </Col>
                    </Row>
                </div>
                <div>
                    <commonApproveRecord :stageId="stageId"/>
                </div>
            </Form>
        </div>
    </div>
</template>
<script>
    import commonApproveRecord from "../common/common-approve-record.vue";

    import {
        getProposalApplicationInfo,
    } from "@/projects/afs-core-business/api/afs-product/product-launch/productLaunch";

    export default {
        name: "proposal-application-approve",
        components:{
            commonApproveRecord
        },
        props: {
            //方案ID
            planId: {
                type:String,
            },
            //流程实例
            stageId:{
                type: [Number, String],
            },
            //是否可以退回
            isBack: {
                type:Boolean,
                required: true,
                default: true
            },
        },
        data() {
            return {
                //校验
                proposalApplicationFormValidate: {
                    approveSuggest: [ {required: true, message: "审批意见不能为空",trigger: "blur"}],
                },
                //表单
                productImplemente:{},
            }
        },
        mounted() {
        },
        methods: {
            //子组件校验，传递到父组件
            validateForm() {
                let result = {};
                let flag = true;
                this.$refs['proposalApplicationFrom'].validate(valid => {
                    if (valid) {
                        flag = true;
                        result["productImplemente"] = this.productImplemente;
                    } else {
                        flag = false;
                    }
                });
                result["flag"] = flag;
                return result;
            },
            //初始化
            getProposalApplicationInfo() {
                this.productImplemente.id = this.planId;
                getProposalApplicationInfo(this.productImplemente).then(res => {
                    if (res.code === "0000") {
                        this.productImplemente = res.data;
                    }
                });
            },
        }
    };
</script>
